Skip to content

fix(durable): land checkpoints when tick barriers step over the interval - #237

Merged
reka18 merged 2 commits into
mainfrom
fix/durable-checkpoint-cadence
Nov 19, 2026
Merged

reka18 merged 2 commits into
mainfrom
fix/durable-checkpoint-cadence

Conversation

@reka18

@reka18 reka18 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What this change does

A checkpoint now lands on any step that crosses a WithCheckpointEvery boundary. Stacked on #236. This is the top of the #214 chain.

checkpointDue compares the ordinals a Record spans, not its own Step. For a plain step the cadence is unchanged. A Tick Record can now checkpoint on a step other than N−1, 2N−1 and so on. Such an instance now compacts, so on a Store without HistoryStore, StateAt can't reach the steps before its latest checkpoint. It answers with the checkpoint's state; with an empty tail, any step after BaselineStep returns ErrStepOutOfRange, as it already did for a run of Fires.

Why

A Tick Record spans several step ordinals, so it could miss the interval forever and the tail grew without limit. A review of #232 found this. It isn't listed in #214.

Still open in #214 after this chain: telemetry on replay (question 7), which #214 defers, and the machine version opt-in (question 6). Question 4 is #263, and question 8 waits for a ruling on #236.

Relates to: #214

Evidence

On GOTOOLCHAIN=go1.27.4:

Command Result
go test -race ./... in durable Pass. TestTimerCheckpoint_BarriersCannotStepOverTheInterval fails on the old formula with a 52-record tail after 50 ticks
mage check (lint, race tests, govulncheck) Pass in all 13 modules

Checklist

  • Commits are signed off (git commit -s) per the DCO
  • Conventional commit messages (type: subject)
  • mage check passes locally (lint + race tests + govulncheck)
  • Tests added/updated for the change
  • Public API changes documented (godoc) and, if applicable, noted for the changelog

@reka18 reka18 added not-ready On every new PR until all review dimensions are confirmed wait:correctness ACR pending: correctness wait:regression-safety ACR pending: regression-safety wait:concurrency-discipline ACR pending: concurrency-discipline wait:replay-determinism ACR pending: replay-determinism wait:api-compatibility ACR pending: api-compatibility wait:missed-context ACR pending: missed-context wait:human-readability ACR pending: human-readability labels Nov 5, 2026
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 62baca3 to 83ecbc2 Compare November 5, 2026 16:38
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 83ecbc2 to bce6f35 Compare November 5, 2026 16:40
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from bce6f35 to ab5eb13 Compare November 5, 2026 16:54
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from ab5eb13 to 52bf074 Compare November 5, 2026 17:09
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 52bf074 to 89ffcbe Compare November 5, 2026 17:14
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 89ffcbe to ed08880 Compare November 5, 2026 17:22
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from ed08880 to a565080 Compare November 5, 2026 17:34
@reka18
reka18 added this pull request to stack #238 November 5, 2026 17:34
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from a565080 to 63db9e4 Compare November 5, 2026 17:42
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 63db9e4 to 7120b33 Compare November 5, 2026 18:04
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 7120b33 to 785fea6 Compare November 5, 2026 18:20
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from fd39fb6 to 6426343 Compare November 5, 2026 19:39
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 6426343 to 6698028 Compare November 5, 2026 19:48
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 6698028 to 5a44b97 Compare November 5, 2026 20:10
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 5a44b97 to 38fa17d Compare November 5, 2026 20:23
@reka18
reka18 removed this pull request from stack #238 November 5, 2026 20:26
@reka18
reka18 added this pull request to stack #239 November 5, 2026 20:26
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 38fa17d to 2dcccbb Compare November 5, 2026 20:52
@reka18
reka18 force-pushed the fix/durable-checkpoint-cadence branch from 2dcccbb to b3d0e06 Compare November 5, 2026 21:02
@reka18 reka18 added ready All ACR dimensions confirmed - clear to merge confirmed:correctness ACR clean: correctness and removed not-ready On every new PR until all review dimensions are confirmed wait:correctness ACR pending: correctness wait:regression-safety ACR pending: regression-safety wait:concurrency-discipline ACR pending: concurrency-discipline wait:replay-determinism ACR pending: replay-determinism wait:api-compatibility ACR pending: api-compatibility wait:missed-context ACR pending: missed-context labels Nov 5, 2026
@reka18

reka18 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Review results. One reviewer per dimension, each reading the others' findings. All seven dimensions have zero blockers on the latest round.

Fixed along the way: a test the new cadence had stopped exercising now pins a non-empty tail, and the StateAt behavior on compacted steps is disclosed.

Known limit: StateAt below the latest checkpoint returns the checkpoint's state without an error on a Store with no history. That predates this PR and needs its own issue.

@reka18

reka18 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Review results. Re-ported onto #236. One AI reviewer per dimension this change touches, each in a clean context: correctness, regression-safety, replay-determinism, API compatibility and human readability. Every one has zero blockers. Concurrency and missed context are untouched by this change and keep their earlier confirmation.

What the reviewers checked:

  • The new rule is due exactly when a Record's span crosses a multiple of N, and for a plain step it's the old (Step+1)%N == 0. Every checkpoint the old rule made still lands, and N consecutive Records always cross a multiple, so the tail stays bounded.
  • appendStep, offerCheckpointLocked and deferred checkpoints all test the same Record, so the snapshot and the offer agree. A checkpoint on a Tick compacts the whole Tick, and its NextStep resumes after it.
  • A probe recovered at every tick of a 30-tick run, for N of 2, 3, 5 and 8, and for a tick that fires two timers. Each matched a run with no checkpoints.
  • StateAt over a compacted window behaves as the CHANGELOG says.

Fixed along the way (2f81ae3): the WithCheckpointEvery godoc now says a checkpoint lands after a step whose span crosses a multiple of n, and that an idle Tick takes no ordinal. The CHANGELOG says exactly what StateAt returns with an empty tail. The cadence test also ticks the recovered Handle.

mage check passes in all 13 modules.

A tick barrier spans several step ordinals, so WithCheckpointEvery could miss
its multiple forever and the tail grew without limit. A checkpoint now lands on
any step that crosses a boundary.

Relates to #214.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
WithCheckpointEvery's godoc now says a checkpoint lands after a step whose span
crosses a multiple of n, and that an idle Tick takes no ordinal. The CHANGELOG
says what StateAt returns with an empty tail. The cadence test also ticks the
recovered Handle.

Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
@reka18

reka18 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

A known gap, out of scope here: with this change a timer-driven instance compacts, so on a Store without HistoryStore, StateAt for a step before the latest checkpoint returns the checkpoint's later state with a nil error. The changelog says so. That was already true for Fire-driven instances. #275 tracks a fix that returns ErrStepOutOfRange instead, which changes StateAt's behavior and is your call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

confirmed:api-compatibility ACR clean: api-compatibility confirmed:concurrency-discipline ACR clean: concurrency-discipline confirmed:correctness ACR clean: correctness confirmed:human-readability ACR clean: human-readability confirmed:missed-context ACR clean: missed-context confirmed:regression-safety ACR clean: regression-safety confirmed:replay-determinism ACR clean: replay-determinism ready All ACR dimensions confirmed - clear to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants